package com.sunshade.common.exception;

/**
 * 统一的异常处理类 对Exception类进行包装，所有的异常均通过此类捕获
 * 
 * @author LiXiangDong
 * @version V1.0, 2012-10-26
 */
public class ECException extends Exception
{
    
    private static final long serialVersionUID = 1L;
    
    /**
     * 错误编码
     */
    private String errorNo = "";
    
    /**
     * 错误描述
     */
    private String errorContent = "";
    
    private Exception exception = null;
    
    /**
     * <默认构造函数>
     * 
     * @param errorNo
     *            错误编码
     * @param errorContent
     *            错误内容
     * @param exception
     *            异常
     */
    public ECException(String errorNo, String errorContent, Exception exception)
    {
        super();
        this.errorNo = errorNo;
        this.errorContent = errorContent;
        this.exception = exception;
    }
    
    public ECException(String errorNo, String errorContent)
    {
        super();
        this.errorNo = errorNo;
        this.errorContent = errorContent;
    }
    
    public String getErrorContent()
    {
        return errorContent;
    }
    
    public void setErrorContent(final String errorContent)
    {
        this.errorContent = errorContent;
    }
    
    public String getErrorNo()
    {
        return errorNo;
    }
    
    public void setErrorNo(final String errorNo)
    {
        this.errorNo = errorNo;
    }
    
    public Exception getException()
    {
        return exception;
    }
    
    public void setException(Exception exception)
    {
        this.exception = exception;
    }
    
    /**
     * Constructs a <code>String</code> with all attributes in name = value
     * format.
     * 
     * @return a <code>String</code> representation of this object.
     */
    public String toString()
    {
        final String TAB = "    ";
        
        StringBuffer retValue = new StringBuffer();
        
        retValue.append("ECException ( ")
                .append(super.toString())
                .append(TAB)
                .append("errorNo = ")
                .append(this.errorNo)
                .append(TAB)
                .append("errorContent = ")
                .append(this.errorContent)
                .append(TAB)
                .append("exception = ")
                .append(this.exception)
                .append(TAB)
                .append(" )");
        
        return retValue.toString();
    }
    
}
